package cn.hchaojie.camp.day12;

public class DemoIntterrupt {
	public static void main(String[] args) {
		Thread t = new Thread(new InterruptRunnable());
		t.start();
		
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		
		System.out.println("中断异步线程");
		t.interrupt();
	}
}

class InterruptRunnable implements Runnable {
	private int count = 10;
	@Override
	public void run() {
		while (!Thread.interrupted()) {
			System.out.println(count++);
		}
	}
	
}